<template>
  <div class="component-addcontract">
    <div class="component-mainHeader">
      <div class="top">
        <div class="topleft">
          <p>
            <span class="iconfont" style="color:#1abc9a;margin-right:3px;">&#xe607;</span> 项目建项
          </p>
        </div>
        <div class="topright">
          <el-button type="info" @click="$router.go(-1)">
            <span style="font-weight:700;margin-right:5px;" class="iconfont">&#xe606;</span>返回
          </el-button>
        </div>
      </div>
      <!-- 中间部分 -->
      <div class="component-main">
        <div class="component-main-left">
          <div class="box1">
            <span class="iconfont">&#xe67e;</span>
            <span>基本信息</span>
            <div class="arrow"></div>
          </div>
        </div>
        <!-- 表单部分 -->
        <div class="component-main-right">
          <div class="box">
            <el-form
              :model="ruleForm"
              :rules="rules"
              ref="ruleForm"
              label-width="100px"
              class="demo-ruleForm"
              :inline="true"
            >
              <el-form-item v-if="$route.params.isFrom=='projectList'" label="所属合同：" prop="belongContract" label-width="150px">
                <el-select v-model="ruleForm.belongContract" placeholder="全部" @change="selectProInfo">
                  <el-option
                    v-for="(item, index) in contractsLists"
                    :key="index"
                    :value="item.conId"
                    :label="item.conName"
                  ></el-option>
                </el-select>
              </el-form-item>

              <el-form-item label="项目名称：" prop="proName" label-width="150px">
                <el-input v-model="ruleForm.proName" clearable></el-input>
              </el-form-item>

              <el-form-item label="项目编码：" style="width: 600px;" prop="proNo" label-width="138px">
                <div v-if="$route.params.isFrom=='projectList'">
                  <el-input style="width: 216px;" v-model="ruleForm.proNo" :disabled="newArrays.proNo==undefined?false:true" clearable></el-input> <span>例：C1824K51</span>
                </div>
                <div v-else>
                  <el-input style="width: 216px;" v-model="ruleForm.proNo" :disabled="$route.params.row==undefined?false:true" clearable></el-input> <span>例：C1824K51</span>
                </div>
              </el-form-item>

              <el-form-item label="内部编号：" prop="innerNo" label-width="150px">
                <el-input v-model="ruleForm.innerNo" clearable></el-input>
              </el-form-item>

              <el-form-item label="委托服开工单号：" label-width="150px">
                <el-input v-model="ruleForm.entrustFkNo" clearable></el-input>
              </el-form-item>

              <el-form-item label="年度：" prop="proYear" label-width="150px">
                <el-input type="number" v-model="ruleForm.proYear" clearable></el-input>
              </el-form-item>

              <el-form-item label="监理单位：" prop="monitorOrg" label-width="150px">
                <el-select v-model="ruleForm.monitorOrg" placeholder="全部">
                  <!-- <el-option label="自己承接" :value="0"></el-option> -->
                  <el-option
                    v-for="(item, index) in list1"
                    :key="index"
                    :value="item.orgId"
                    :label="item.orgName"
                  ></el-option>
                </el-select>
              </el-form-item>

              <el-form-item label="设计单位：" prop="designOrg" label-width="150px">
                <el-select v-model="ruleForm.designOrg" placeholder="全部">
                  <el-option
                    v-for="(item, index) in list2"
                    :key="index"
                    :value="item.orgId"
                    :label="item.orgName"
                  ></el-option>
                </el-select>
              </el-form-item>

              <el-form-item label="施工单位：" prop="workOrg" label-width="150px">
                <el-select v-model="ruleForm.workOrg" placeholder="全部">
                  <el-option
                    v-for="(item, index) in list3"
                    :key="index"
                    :value="item.orgId"
                    :label="item.orgName"
                  ></el-option>
                </el-select>
              </el-form-item>

              <el-form-item label="客户经理：" prop="custManager" label-width="150px">
                <el-input v-model="ruleForm.custManager" clearable></el-input>
              </el-form-item>

              <el-form-item label="客户经理联系方式：" prop="custManagerContact" label-width="150px">
                <el-input v-model="ruleForm.custManagerContact" clearable></el-input>
              </el-form-item>

              <el-form-item label="客户类型：" prop="custType" label-width="150px">
                <el-input v-model="ruleForm.custType" clearable></el-input>
              </el-form-item>

              <el-form-item label="城市：" prop="proCity" label-width="150px">
                <el-input v-model="ruleForm.proCity" clearable placeholder="例:广州市"></el-input>
              </el-form-item>

              <el-form-item label="区域：" prop="proArea" label-width="150px">
                <el-input v-model="ruleForm.proArea" clearable placeholder="例:白云区"></el-input>
              </el-form-item>

              <el-form-item label="镇区：" prop="proTown" label-width="150px">
                <el-input v-model="ruleForm.proTown" clearable placeholder="例:增城区"></el-input>
              </el-form-item>

              <el-form-item label="项目地址：" label-width="150px" style="width:700px;" required>
                <el-col :span="10">
                  <el-form-item prop="proAddr1" style="width: 200px;">
                    <el-input v-model="ruleForm.proAddr1" @input="handleSearchAddress" clearable placeholder="请输入四级地址"></el-input>
                  </el-form-item>
                </el-col>
                <el-col class="line" :span="2">/</el-col>
                <el-col :span="10">
                  <el-form-item prop="proAddr2" style="width: 200px;">
                    <el-input v-model="ruleForm.proAddr2" @input="handleSearchAddress" clearable placeholder="请输入五级地址"></el-input>
                  </el-form-item>
                </el-col>
              </el-form-item>

              <el-form-item
                label="项目经纬度："
                label-width="97px"
                style="width:740px;"
              >
                <el-input v-model="lng" style="width:200px;" clearable placeholder="请输入经度"></el-input> , <el-input style="width:200px;" v-model="lat" clearable placeholder="请输入纬度"></el-input>
              </el-form-item>

              <!-- 类别 -->
              <el-form-item label="类别：" label-width="150px" style="margin-left: -16px;">
                <el-input
                  placeholder="请选择类别"
                  v-model="ruleForm.dataV"
                  @click.native="chooseType"
                ></el-input>
              </el-form-item>

              <!-- 项目专业弹窗 -->
              <div class="component-model">
                <div class="modelll">
                  <el-dialog title="选择类别" :visible.sync="dialogVisible" width="800px">
                    <div class="input-box">
                      <div>
                        <span
                          class="upload"
                          style="
                          display:inline-block;
                          color:#666;width: 105px;
                          height: 30px;
                          border: 1px solid #e4e4e4;
                          background-color:#fff;
                          font-size:14px;
                          line-height:30px;
                          margin-left:380px;
                          margin-top:5px;
                          "
                          @click="addRadio"
                        >+&nbsp;&nbsp;添加类别</span>
                      </div>
                      <div class="checkbox">
                        <el-radio-group v-model="ruleForm.list">
                          <el-radio
                            v-for="(item,index) in checkList"
                            :key="index"
                            :label="item.const_id"
                            style="
                        width: 50px;
                        height: 50px;
                        margin-right: 80px;
                        margin-top: 30px;
                        "
                            @change="changes"
                          >{{item.const_name}}</el-radio>
                        </el-radio-group>
                      </div>
                    </div>
                    <span slot="footer" class="dialog-footer">
                      <el-button @click="dialogVisible = false">取消</el-button>
                      <el-button @click="dialogVisible = false;selectData()">确定</el-button>
                    </span>
                  </el-dialog>
                  <el-dialog title="添加类别" :visible.sync="dialogAdd" width="450px">
                    <el-form
                      :model="ruleForms"
                      ref="ruleForms"
                      label-width="100px"
                      class="demo-ruleForm"
                    >
                      <el-form-item label="类别名称：" prop="name" label-width="100px">
                        <el-input v-model="ruleForms.name" style="margin-left：0px"></el-input>
                      </el-form-item>
                    </el-form>
                    <span slot="footer" class="dialog-footer">
                      <el-button @click="dialogAdd = false">取消</el-button>
                      <el-button @click="dialogAdd = false;addPerson()">确定</el-button>
                    </span>
                  </el-dialog>
                </div>
              </div>

              <!-- 时间 -->
              <el-form-item label="工单派发日期：" prop="orderDispatchDate" label-width="150px" required>
                <el-date-picker
                  v-model="ruleForm.orderDispatchDate"
                  type="date"
                  placeholder="选择日期"
                  format="yyyy 年 MM 月 dd 日"
                  value-format="timestamp"
                  default-time="00:00:00"
                ></el-date-picker>
              </el-form-item>
              <el-form-item label="工单接受日期：" prop="orderAcceptDate" label-width="150px" required>
                <el-date-picker
                  v-model="ruleForm.orderAcceptDate"
                  type="date"
                  placeholder="选择日期"
                  format="yyyy 年 MM 月 dd 日"
                  value-format="timestamp"
                  default-time="00:00:00"
                ></el-date-picker>
              </el-form-item>
              <el-form-item prop="sworkDate" label="预计开工日期：" label-width="150px" required>
                <el-date-picker
                  v-model="ruleForm.sworkDate"
                  type="date"
                  placeholder="选择日期"
                  format="yyyy 年 MM 月 dd 日"
                  value-format="timestamp"
                  default-time="00:00:00"
                ></el-date-picker>
              </el-form-item>
              <el-form-item label="预计完工日期：" prop="eworkDate" label-width="150px" required>
                <el-date-picker
                  v-model="ruleForm.eworkDate"
                  type="date"
                  placeholder="选择日期"
                  format="yyyy 年 MM 月 dd 日"
                  value-format="timestamp"
                  default-time="00:00:00"
                ></el-date-picker>
              </el-form-item>

              <!-- 涉及管道 -->

              <el-form-item
                style=" margin-left: 54px;"
                label-width="150px"
                label="涉及管道"
                prop="resource"
              >
                <el-radio-group v-model="ruleForm.resource">
                  <el-radio label="1">是</el-radio>
                  <el-radio>否</el-radio>
                </el-radio-group>
              </el-form-item>

              <el-form-item
                style=" margin-left: 54px;"
                label-width="150px"
                label="涉及线路"
                prop="resource1"
              >
                <el-radio-group v-model="ruleForm.resource1">
                  <el-radio label="2">是</el-radio>
                  <el-radio>否</el-radio>
                </el-radio-group>
              </el-form-item>

              <el-form-item
                style=" margin-left: 54px;"
                label-width="150px"
                label="涉及设备"
                prop="resource2"
              >
                <el-radio-group v-model="ruleForm.resource2">
                  <!-- <el-radio label="是"></el-radio>
                  <el-radio label="否"></el-radio>-->
                  <el-radio label="3">是</el-radio>
                  <el-radio>否</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item
                style=" margin-left: 54px;"
                label-width="150px"
                label="涉及熔纤"
                prop="resource3"
              >
                <el-radio-group v-model="ruleForm.resource3">
                  <el-radio label="4">是</el-radio>
                  <el-radio>否</el-radio>
                </el-radio-group>
              </el-form-item>

              <el-form-item>
                <el-button
                  type="primary"
                  v-show="isShowBtn"
                  @click="submitForm('ruleForm')"
                  style="margin-left:180px;width:210px"
                >创建项目</el-button>
              </el-form-item>

              <el-form-item style="margin-left: 80px;" label-width="300px">
                <el-upload
                  ref="upload"
                  class="upload-demo"
                  :multiple="true"
                  action="/api/web/sysFile/uploadFile"
                  :headers="myheader"
                  :file-list="fileList"
                  :auto-upload="true"
                  :data="FileObject"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :before-remove="beforeRemove"
                  :before-upload="beforeAvatarUpload"
                  :on-exceed="handleExceed"
                  :limit="3"
                  :on-success="handChange"
                >
                  <span style="vertical-align:top">导入相关文件：</span>
                  <el-button
                    size="small"
                    type="primary"
                    style=" width: 202px;
                    height: 45px;
                    border: 1px solid #e4e4e4;
                    "
                  >导入此项目文件</el-button>
                </el-upload>
              </el-form-item>
              <!--accept=".doc,.DOC,.pdf,.PDF,.dwg,.xls,.xlsx,.zip,.rar,.DWG"-->
              <div style="font-size: 12px;color: #ccc;margin-top: -10px;margin-left: 120px;margin-bottom: 12px;">文件大小不能超过10M</div>
            </el-form>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
/*  import ElCol from "element-ui/packages/col/src/col";
  window.init = function() {
    var map = new AMap.Map("container", {
      center: [117.000923, 36.675807],
      zoom: 11
    });
  };*/
  export default {
//    components: {ElCol},
    name: "buildPro",
    data() {
      return {
        myheader:{token:localStorage.getItem("token")},
        isShowBtn:true,//是否显示创建项目按钮 建项成功后隐藏该按钮
        news:{},
        // 监理单位
        list1: [],//监理单位
        list2: [],//设计单位
        list3:[],//施工单位
        newArray: {},
        fileCode: {},
        chooseList: [],
        checkList: [],//添加类别
        modelTitle: "选择项目专业",
        dialogVisible: false,
        dialogAdd: false,
        flag: 0,
        ruleForms: { name: "" },
        ruleForm: {
          proName: "",
          proNo: "",
          innerNo: "",
          proYear: "",
          monitorOrg: "",
          designOrg: "",
          custManager: "",
          proAddr: "",
          type: [],
          pro_model: "",
          resource: "",
          resource1: "",
          resource2: "",
          resource3: "",
          list: [],
          sworkDate: "",
          orderDispatchDate: "",
          orderAcceptDate:'',
          eworkDate: "",
          lable1:"自己承接",
          lable2:"挂靠方式",
          entrustFkNo:'',
          workOrg:'',//施工单位
          custManagerContact:'',//客户经理联系方式
          custType:'',//客户类型
          proCity:'',//城市
          proArea:'',//区域
          proTown:'',//镇区
          dataV: "",//选择类别
          proAddr1:'',//四级地址
          proAddr2:'',//五级地址
          belongContract:'',//所属合同
        },
        rules: {
          proName: [
            { required: true, message: "请输入项目名称", trigger: "blur" },

          ],
          proNo: [
            { required: true, message: "请输入项目编号", trigger: "blur" },

          ],
          innerNo: [
            { required: true, message: "请输入内部编号", trigger: "blur" },

          ],
          belongContract:[
            { required: true, message: "请选择所属合同", trigger: "change" },
          ],
          monitorOrg:[
            { required: true, message: "请选择监理单位", trigger: "change" },
          ],
          designOrg:[
            { required: true, message: "请选择设计单位", trigger: "change" },
          ],
          workOrg:[
            { required: true, message: "请选择施工单位", trigger: "change" },
          ],
          custType:[
            { required: true, message: "请选择客户类型", trigger: "change" },
          ],
          proCity:[
            { required: true, message: "请选择城市", trigger: "change" },
          ],
          proArea:[
            { required: true, message: "请选择区域", trigger: "change" },
          ],
          proTown:[
            { required: true, message: "请选择镇区", trigger: "change" },
          ],

          // 年度
          proYear: [
            { required: true, message: "请输入年度且为数字", trigger: "blur" },

          ],
          entrustFkNo:[
            { required: true, message: "请输入委托服开工单号", trigger: "blur" },
          ],

          custManager: [
            { required: true, message: "请输入客户经理", trigger: "blur" },
          ],
          custManagerContact:[
            { required: true, message: "请输入客户经理联系方式", trigger: "blur" },
          ],
          proAddr1: [
            { required: true, message: "请输入四级地址", trigger: "blur" },
          ],
          proAddr2: [
            { required: true, message: "请输入五级地址", trigger: "blur" },
          ],
          longlat: [
            { required: true, message: "请输入经纬度", trigger: "blur" },
          ],
          dataV:[
            { required: true, message: "请选择类别", trigger: "blur" },
          ],

          pro_model: [
            {
              required: true,
              message: "请输入经营模式",
              trigger: "blur"
            },

          ],
          sworkDate: [{ required: true, message: "请选择开工日期", trigger: "blur" }],
          eworkDate: [{ required: true, message: "请选择完工日期", trigger: "blur" }],
          receptionDate: [{ required: true, message: "请选择完工日期", trigger: "blur" }],
          orderDispatchDate:[{ required: true, message: "请选择工单派发日期", trigger: "blur" }],
          orderAcceptDate:[{ required: true, message: "请选择工单接受日期", trigger: "blur" }]
        },
        proId: "",// 编辑 进来传过来的id
        // 上传文件
        fileList: [],
        FileObject: {
          bizType: "project.design.drawing",
          parentId: ""
        },
        lng: 0,
        lat: 0,
        newList: [],
        contractsLists:[],//所属合同列表
        newArrays:{}
      };
    },
    created() {
      //  查看传进来的id
      this.getId();
      this.getList();
      this.getcompany();//监理单位
      this.getcompany1();//设计单位
      this.getcompany2();//施工单位
    },
    mounted(){
        console.log(this.$route.params)
      if(this.$route.params.isFrom=='projectList'){
//        this.ruleForm.proNo = this.newArrays.proNo || ''
      }else{
        if(this.$route.params.row == undefined){
          this.ruleForm.proNo = this.$route.params.proNo
        }else{
          this.ruleForm.proNo = this.$route.params.row.proNo
        }
      }

      this.vsClick();
      this.belongContracts();//查询合同名称和项目编码
    },
    methods: {
      selectProInfo(){
        this.newArrays = this.contractsLists.find((item) => {
          if(item.conId === this.ruleForm.belongContract){
            return item
          }
        });
        this.ruleForm.proNo = this.newArrays.proNo;
        console.log(this.newArrays)
      },
      //查询合同名称和项目编码
      belongContracts(){
        let suCb = res => {
          this.contractsLists = res.data.data;
        };
        let req = {
          url: "/api/web/proContract/getConNameProNo",
          methods: "post",
          data: {},
          success: suCb
        };
        this.$https(req);
      },
      //点击选择类别的弹框
      chooseType(){
        this.$nextTick(function () {
          this.dialogVisible = true;
          this.vsClick()
        })
      },
      // 获取监理单位
      getcompany() {
        let that = this;
        let params = {
          outType: "3"
        };
        let suCb = res => {
          that.list1 = res.data.data;
        };
        let erCb = res => {
          console.log(res);
        };

        let req = {
          url: "/api/web/sysOrg/getOrgNamebyType",
          methods: "post",
          data: params,
          success: suCb,
          error: erCb
        };
        that.$https(req);
      },
      // 获取设计单位的 列表
      getcompany1() {
        let that = this;
        let params = {
          outType: "4"
        };
        let suCb = res => {
          that.list2 = res.data.data;
        };
        let erCb = res => {
          console.log(res);
        };
        let req = {
          url: "/api/web/sysOrg/getOrgNamebyType",
          methods: "post",
          data: params,
          success: suCb,
          error: erCb
        };
        that.$https(req);
      },
      //获取施工单位列表
      getcompany2(){
        let that = this;
        let params = {
          outType: "7"
        };
        let suCb = res => {
          console.log(res.data,"请求施工单位成功");
          that.list3 = res.data.data;
        };
        let erCb = res => {
          console.log(res);
        };
        let req = {
          url: "/api/web/sysOrg/getOrgNamebyType",
          methods: "post",
          data: params,
          success: suCb,
          error: erCb
        };
        that.$https(req);
      },
      // 上传文件
      // 上传成功
      handChange(res, file, fileList) {
        if(res.flag==1){
          this.fileCode = fileList[0].response;
          this.$msg("文件导入成功");
          this.$router.push({
            name: "contractList"
          });
        }else if(res.flag==0){
          this.$erMsg("导入失败,请先创建项目");
        }
      },
      handleRemove(res,file, fileList) {
        if(file.status == "success"){
          let params = {
            fileUrl: this.fileCode.fileUrl,
            parentId: this.fileCode.conId
          };
          let suCb = res => {
            this.fileList = [];
          };
          let req = {
            url: "/api/web/sysFile/deleteFile",
            methods: "post",
            data: params,
            success: suCb,
          };
          this.$https(req);
        }else{
          this.fileList = [];
        }
      },
      handlePreview(file) {
        console.log(file);
      },
      handleExceed(files, fileList) {
        this.$message.warning(
          `当前限制选择 3 个文件，本次选择了 ${
            files.length
            } 个文件，共选择了 ${files.length + fileList.length} 个文件`
        );
      },
      beforeRemove(file, fileList) {
//        return this.$confirm(`确定移除 ${file.name}？`);
      },
      beforeAvatarUpload(file) {
        const isLt2M = file.size / 1024 / 1024 < 10;
        if (!isLt2M) {
          this.$message.error('上传文件大小不能超过 10MB!');
        }
        return isLt2M;
      },
      //  获取传过来的id
      getId() {
        console.log(this.$route.params.proId,"点击编辑项目id");
        this.proId = this.$route.params.proId;
      },
      // 获取项目信息列表的接口
      getList() {
        // 判断是否有proId 来是否调接口 回显 编辑页面
        if (this.proId) {
          let that = this;
          let params = {
            proId: that.proId
          };
          let suCb = res => {
            console.log(res,"请求回显成功");
            that.ruleForm = res.data.data[0];
            that.lng = that.ruleForm.proLng;
            that.lat = that.ruleForm.proLat;
            that.ruleForm.dataV =  that.ruleForm.proMajor;
            that.ruleForm.proYear = that.ruleForm.proYear+""
            that.newList = that.ruleForm.majorType.split(",");//单选框
            console.log(that.newList);
            // 拿到的newList的值无法在下面 的  panduanll函数里面拿到
            that.panduanll();
          };
          let erCb = res => {
            console.log(res);
          };
          let req = {
            url: "/api/web/proProject/selectProShow",
            methods: "post",
            data: params,
            success: suCb,
            error: erCb
          };
          console.log(req.data);
          that.$https(req);
        }
      },
      // 添加按钮
      addRadio() {
        this.dialogAdd = true;
      },
      // 添加类别按钮
      addPerson() {
        let that = this,
          params = {
            constName: that.ruleForms.name,
            typeCode: "proMajor"
          };
        let suCb = res => {
            that.vsClick();
          },
          erCb = res => {
            console.log(res);
          },
          req = {
            url: "/api/web/sysConst/addconst",
            methods: "post",
            data: params,
            success: suCb,
            error: erCb
          };
        console.log(req.data);
        that.$https(req);
      },
      changes() {
        this.newArray = this.checkList.find(item => {
          if (item.const_id === this.ruleForm.list) {
            return item;
          }
        });
        console.log(this.newArray);
        // undefined
      },
      // 将选中的值展现到input中
      selectData() {
        this.$nextTick(function () {
          this.ruleForm.dataV = this.newArray.const_name;
        })
      },
      // 判断项目类型
      panduan() {
        this.chooseList = [];
        if (this.ruleForm.resource == "1") {
          this.ruleForm.resource = "1";
          this.chooseList.push(1);
        } else if (this.ruleForm.resource !== "1") {
          this.ruleForm.resource = "";
        }
        if (this.ruleForm.resource1 == "2") {
          this.ruleForm.resource1 = "2";
          this.chooseList.push(2);
        } else if (this.ruleForm.resource1 !== "2") {
          this.ruleForm.resource1 = "";
        }
        if (this.ruleForm.resource2 == "3") {
          this.ruleForm.resource2 = "3";
          this.chooseList.push(3);
        } else if (this.ruleForm.resource2 !== "3") {
          this.ruleForm.resource2 = "";
        }
        if (this.ruleForm.resource3 == "4") {
          this.ruleForm.resource3 = "4";
          this.chooseList.push(4);
        } else if (this.ruleForm.resource3 !== "4") {
          this.ruleForm.resource3 = "";
        }
        console.log(this.chooseList);
      },
      //  将返回的数组 转为值
      //  回显单选框
      panduanll() {
        for (let i in this.newList) {
          console.log(this.newList[i]);
          if (this.newList[i] == "1") {
            this.ruleForm.resource = "1";
          } else if (this.newList[i] == "2") {
            this.ruleForm.resource1 = "2";
          } else if (this.newList[i] == "3") {
            this.ruleForm.resource2 = "3";
          } else if (this.newList[i] == "4") {
//            this.newList[i] = "2";
            this.ruleForm.resource3 = "4";
          }
        }
      },
      //  调接口获取类别
      vsClick() {
        console.log(1);
        let that = this,
          params = {
            object: "proMajor"
          };
        console.log(params);

        console.log(that.$route.params.parentId);

        let suCb = res => {
            console.log(res);
            // 获取 类别列表
            that.checkList = res.data.data;

            console.log(that.ruleForm);


            //  if(that.ruleForm.proMajor.length>0){

            that.news = that.checkList.find((item)=>{
              if(item.const_name == that.ruleForm.dataV){
                return item
              }
            })
            console.log(that.news,790)
            // }
            console.log(that.checkList,786);
          },
          erCb = res => {
            console.log(res);
          },
          req = {
            url: "/api/web/proProject/selectConst",
            methods: "post",
            data: params,
            success: suCb,
            error: erCb
          };
        console.log(req.data);
        that.$https(req);
      },
      /**
       *  通过项目地址自动获取项目经纬度并回显的方法
       */
      handleSearchAddress() {
        let that = this;
        let address = {
          address: this.ruleForm.proAddr1+this.ruleForm.proAddr2
        };
        let suCb = res => {
          if(res.data.message!=null){
            let lnglat = res.data.message.split(",");
            that.lng = parseFloat(lnglat[0]);
            that.lat = parseFloat(lnglat[1]);
          }
        };
        let erCb = res => {
          that.lng = 0;
          that.lat = 0;
        };
        let params = {
          url: "/api/web/proMapWorkDetail/getLonLat",
          methods: "post",
          data: address,
          success: suCb,
          error: erCb
        };
        this.$https(params);
      },

      // 提交表单
      submitForm(formName) {
        // 请求前调用赋值
        this.panduan();
        this.$refs[formName].validate(valid => {
          if (valid) {
            let that = this;
            if(that.ruleForm.dataV==""||that.ruleForm.dataV==undefined){
              that.$message.error('请选择类别');
              return false;
            }
            if(that.ruleForm.orderAcceptDate>=that.ruleForm.orderDispatchDate && that.ruleForm.orderAcceptDate<=that.ruleForm.sworkDate && that.ruleForm.sworkDate<=that.ruleForm.eworkDate){
              let params = {
                proId: that.proId || '',//项目Id
                parentId:that.$route.params.isFrom=='projectList'? that.ruleForm.belongContract : (that.$route.params.row ==undefined ? that.$route.params.conId : that.$route.params.row.conId), //归属合同id
                proName: that.ruleForm.proName,//项目名称
                proNo: that.ruleForm.proNo,//项目编号
                innerNo: that.ruleForm.innerNo,//内部编号
                entrustFkNo:that.ruleForm.entrustFkNo,//委托服开工单号
                proYear: that.ruleForm.proYear+"",//项目年份
                monitorOrg: that.ruleForm.monitorOrg,//监理单位
                designOrg: that.ruleForm.designOrg,//设计单位
                workOrg:that.ruleForm.workOrg,//施工单位
                custManager:that.ruleForm.custManager,//客户经理
                custManagerContact:that.ruleForm.custManagerContact,//客户经理联系方式
                custType:that.ruleForm.custType,//客户类型
                proCity:that.ruleForm.proCity,//城市
                proArea:that.ruleForm.proArea,//区域
                proTown:that.ruleForm.proTown,//镇区
                proAddr: that.ruleForm.proAddr1+'/'+that.ruleForm.proAddr2,//项目地址
                proLng: that.lng + "",//项目经度
                proLat: that.lat + "",//项目纬度
                proMajor: that.ruleForm.list,//类别专业Id
                orderDispatchDate:that.ruleForm.orderDispatchDate+"",//工单派发日期
                orderAcceptDate:that.ruleForm.orderDispatchDate+"",//工单接受日期
                sworkDate: that.ruleForm.sworkDate + "",//预计开工日期
                eworkDate: that.ruleForm.eworkDate + "",//预计完工日期
                majorType: that.chooseList.join(","),//施工类型
                belongOrg: that.$route.params.isFrom=='projectList'?this.newArrays.belongOrg:(that.$route.params.row ==undefined ? that.$route.params.belongOrg : that.$route.params.row.belongOrg),//归属机构

                proModel: "",//经营模式
                entrustDate:'',//委托日期
                receptionDate: "",//验收日期
                createDate:'',//创建日期
                createUser:'',//创建人id
                proLeaderName: "",//项目负责人
                budgetProfitRate:'', //利润值
              };
              let suCb = res => {
                that.$msg("项目建项成功！");
                that.isShowBtn = false;
                //  将建项成功的 id 给 文件
                that.FileObject.parentId = res.data.param.proId;
              };
              let erCb = res => {
                console.log(res);
              };
              let req = {
                url: "/api/web/proProject/addProProject",
                methods: "post",
                data: params,
                success: suCb,
                error: erCb
              };
              that.$https(req);
            }else{
              this.$erMsg('预计完工日期应大于预计开工日期大于工单接受日期大于工单派发日期')
            }
          } else {
            this.$erMsg("请按红色字的提示进行修改完善")
            return false;
          }
        });
      }
    }
  };
</script>
<style scoped>
  /* 地图样式 */
  .amap-demo {
    height: 300px;
  }
  .component-main {
    width: 1102px;
    /* height: 1400px; */
    margin: 0 auto;
    margin-top: 49px;
    background-color: #fff;
    border: 1px solid #e4e4e4;
    border-top: none;
  }
  .component-main-left {
    width: 180px;
    height: 1825px;
    border: 1px solid #e4e4e4;
    padding-top: 50px;
    float: left;
    border-top: none;
  }
  .box1 {
    position: relative;
    width: 175px;
    height: 50px;
    text-align: left;
    line-height: 50px;
    background-color: #9ea7b4;
    color: #fff;
    padding-left: 5px;
  }
  .box1 .arrow {
    position: absolute;
    width: 0;
    height: 0;
    top: -40px;
    left: 180px;
    border-width: 25px 0 25px 25px;
    border-style: solid;
    border-color: transparent transparent transparent #9ea7b4; /*透明 透明 透明 灰*/
    margin: 40px auto;
  }

  /* 表单部分 */

  .component-main-right {
    height: 1774px;
    float: right;
    width: 918px;
    margin: 0 auto;
    border-top: none;
    padding-top: 100px;
    border-bottom: 1px solid #e4e4e4;

    border-right: 1px solid #e4e4e4;
  }

  .box {
    width: 500px;
    margin: 0 auto;
  }
  .box .el-button--primary {
    color: #fff;
    background-color: #1abc9c;
    border-color: #1abc9c;
  }
  .box .el-form-item {
    width: 400px;
  }

  .el-form-item .el-form-item__label {
    width: 110px;
  }

  .el-form-item__content {
    margin-left: -103px;
  }

  .main-input {
    width: 90px;
    height: 40px;
    border: 1px solid #e4e4e4;
    margin-left: -2px;
    border-left: none;
  }

  /* 弹窗样式 */
  .model-input {
    width: 190px;
    height: 10px;
    border: 1px solid #ccc;
    padding: 10px;
    color: #ccc;
  }

  .input-box {
    margin-bottom: 100px;
  }
  .search {
    width: 40px;
    height: 30px;
    border: 1px solid #ccc;
    border-left: none;
    line-height: 30px;
    background-color: #ccc;
  }

  .radio-group {
    padding-top: 30px;
    padding-left: 30px;
  }

  .radio-group .el-radio {
    height: 30px;
  }

  .addpro {
    display: inline-block;
    width: 100px;
    height: 30px;
    line-height: 30px;
    border: 1px solid #ccc;
    background-color: #fff;
    color: #ccc;
  }
  .addpro:hover {
    cursor: pointer;
  }

  .component-searchHeader .search-header {
    width: 1100px;
    box-sizing: border-box;
    border: 1px solid rgba(228, 228, 228, 1);
    background-color: rgba(255, 255, 255, 1);
    margin: 20px auto 0;
  }

  .component-searchHeader .search-header .left-title {
    display: flex;
    justify-content: space-between;
    width: 100%;
    background-color: rgba(243, 243, 243, 1);
    height: 45px;
    box-sizing: border-box;
  }

  .component-searchHeader .search-header .left-title .left-text {
    width: 20%;
    color: #666;
    line-height: 45px;
    font-family: "微软雅黑";
    font-weight: 400;
    font-size: 12px;
    text-align: left;
    margin: 0 0 0 30px;
  }

  .component-searchHeader .right {
    width: 70%;
    display: flex;
    justify-content: flex-end;
    margin-right: 30px;
  }

  .component-searchHeader .right button {
    padding: 0 15px;
    height: 30px;
    margin: 6px 5px;
    line-height: 30px;
    font-size: 12px;
    color: #666;
    background-color: #fff;
    border: 1px solid #ccc;
  }

  .component-searchHeader .right button:hover {
    background-color: #f3f3f3;
  }

  .component-search-box {
    width: 1100px;
    height: 60px;
    box-sizing: border-box;
    background-color: #fff;
    border: 1px solid #e4e4e4;
    border-top: none;
    margin: 0 auto;
    text-align: left;
    padding-left: 30px;
    line-height: 60px;
  }

  .component-search-box .el-input__inner {
    height: 35px;
    display: inline-block;
  }

  .component-listHeader .search-header {
    width: 1100px;
    box-sizing: border-box;
    border: 1px solid rgba(228, 228, 228, 1);
    background-color: rgba(255, 255, 255, 1);
    margin: 20px auto 0;
    border-bottom: 0;
  }

  .component-listHeader .search-header .left-title {
    display: flex;
    justify-content: space-between;
    width: 100%;
    background-color: rgba(243, 243, 243, 1);
    height: 45px;
    box-sizing: border-box;
  }

  .component-listHeader .search-header .left-title .left-text {
    width: 20%;
    color: #666;
    line-height: 45px;
    font-family: "微软雅黑";
    font-weight: 400;
    font-size: 12px;
    text-align: left;
    margin: 0 0 0 30px;
  }

  .component-listHeader .search-header .right {
    width: 70%;
    display: flex;
    justify-content: flex-end;
    margin-right: 10px;
  }

  .component-listHeader .search-header .right button {
    padding: 0 15px;
    height: 30px;
    width: 80px;
    margin: 6px 5px;
    line-height: 30px;
    font-size: 14px;
    color: #666;
    background-color: #fff;
    border: 1px solid #ccc;
  }
  .component-listHeader .search-header .right button:hover {
    background-color: #f3f3f3;
  }
  .component-listHeader .search-header .right .right-select-margin {
    margin-top: 6px;
    margin-right: 8px;
  }
  .map_btn {
    display: inline-block;
    width: 215px;
    height: 42px;
    line-height: 42px;
    border: 1px solid #e4e4e4;
    background-color: #1abc9a;
    border-radius: 5px;
    color: #fff;
    margin-top: 20px;
  }
  .map_btn:hover {
    cursor: pointer;
  }
  .checkbox {
    text-align: left;
    margin: 20px 0;
  }

  .upload:hover {
    cursor: pointer;
    background-color: #1abc9a;
  }

  .el-form .el-form-item .el-form-item__content {
    margin-left: 0px;
  }
</style>
